use HardwaresRUsDb

--Category Table including a parent key relating back to CategoryID
CREATE TABLE dbo.Category
	(CategoryId int PRIMARY KEY NOT NULL,
	 Description nvarchar(100) NULL,
	 ParentCategoryId int NULL constraint [FK_ParentCategory_Category] FOREIGN KEY
					(ParentCategoryId) REFERENCES dbo.Category(CategoryId))

GO
	 
--Products table with foreign key relating to Category.CategoryId
CREATE TABLE dbo.Product
	(ProductId int PRIMARY KEY NOT NULL,
	 Title nvarchar(100) NOT NULL,
	 TagLine nvarchar(MAX) NULL,
	 Description nvarchar(MAX) NULL,
	 CategoryId int NOT NULL constraint [FK_ProductCategoryId_CategoryId] FOREIGN KEY
					(CategoryId) REFERENCES dbo.Category(CategoryId),
	 ImageUrl nvarchar(255) NULL,
	 Keywords nvarchar(200) NULL)
					
GO

--Download table with foreign key relating to Category.CategoryId
CREATE TABLE dbo.Download
	(DownloadId int PRIMARY KEY NOT NULL,
	 Title nvarchar(100) NOT NULL,
	 Description nvarchar(MAX) NULL,
	 CategoryId int NOT NULL constraint [FK_DownloadCategoryId_CategoryId] FOREIGN KEY
					(CategoryId) REFERENCES dbo.Category(CategoryId),
	 DownloadUrl nvarchar(255) NOT NULL)

GO

--FAQ table with a short and long version of a question
CREATE TABLE dbo.Faq
	(FaqId int PRIMARY KEY NOT NULL,
	 QuestionShort nvarchar(200) NOT NULL,
	 QuestionLong nvarchar(MAX) NULL,
	 Answer nvarchar(MAX) NULL)

GO

--User table full of login details
CREATE TABLE dbo.Users
	(UserId int PRIMARY KEY NOT NULL,
	 Username varchar(20) NOT NULL,
	 Password varchar(20) NOT NULL)